//
//  Order.m
//  OrgOnline
//
//  Created by kiko on 16/3/7.
//  Copyright © 2016年 kiko. All rights reserved.
//
#define TEXTCOLOR ([UIColor colorWithRed:40.0f/255.0f green:40.0f/255.0f blue:40.0f/255.0f alpha:1])
#define SELECTED_TEXTCOLOR ([UIColor colorWithRed:1.0f/255.0f green:146.0f/255.0f blue:242.0f/255.0f alpha:1])

#import "SelectButton.h"
#import "Order.h"

@interface Order (){
    NSMutableArray *buttonList;
    NSArray *titleList;
    
    NSArray *dataList;

}
@end

@implementation Order

- (void)viewDidLoad {
    [super viewDidLoad];
    self.title = @"订单";
    self.view.backgroundColor=[UIColor colorWithRed:241.0f/255.0f green:242.0f/255.0f blue:247.0f/255.0f alpha:1];
    [self viewDidLoadBlue];
    //[self configHeadRight];
    [self configContent];
    // Do any additional setup after loading the view.
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

-(void)configContent{
    titleList=@[@"全部",@"待支付",@"进行中",@"待评价"];
    
    UIView *menuview=[[UIView alloc] initWithFrame:CGRectMake(0, 66, swidth, 40.5)];
    menuview.backgroundColor=[UIColor whiteColor];
    [self.view addSubview:menuview];
   // [self configMenu];
    
    
    for(NSInteger i=0;i<titleList.count ;i++){
        SelectButton *but=[[SelectButton alloc] initWithFrame:CGRectMake(i*swidth/4, 0, swidth/4, 40.5)];
        but.textlabel.text=[titleList objectAtIndex:i];
        but.tag=i;
        [but addTarget:self action:@selector(menu:) forControlEvents:UIControlEventTouchUpInside];
        [menuview addSubview:but];
        [buttonList addObject:but];
    }
    _selectedIndex = -1;
//    SelectButton *but1=[[SelectButton alloc] initWithFrame:CGRectMake(0, 0, swidth/4, 40.5)];
//    but1.textlabel.text=@"全部";
//    but1.tag=1;
//    [but1 addTarget:self action:@selector(menu:) forControlEvents:UIControlEventTouchUpInside];
//    [menuview addSubview:but1];
//    
//    
//    SelectButton *but2=[[SelectButton alloc] initWithFrame:CGRectMake(swidth/4, 0, swidth/4, 40.5)];
//    but2.textlabel.text=@"待支付";
//    but2.tag=2;
//    [but2 addTarget:self action:@selector(menu:) forControlEvents:UIControlEventTouchUpInside];
//    [menuview addSubview:but2];
//    
//    SelectButton *but3=[[SelectButton alloc] initWithFrame:CGRectMake(swidth/2, 0, swidth/4, 40.5)];
//    but3.textlabel.text=@"进行中";
//    but3.tag=3;
//    [but3 addTarget:self action:@selector(menu:) forControlEvents:UIControlEventTouchUpInside];
//    [menuview addSubview:but3];
//    
//    SelectButton *but4=[[SelectButton alloc] initWithFrame:CGRectMake(3*swidth/4, 0, swidth/4, 40.5)];
//    but4.textlabel.text=@"待评价";
//    but4.tag=4;
//    [but4 addTarget:self action:@selector(menu:) forControlEvents:UIControlEventTouchUpInside];
//    [menuview addSubview:but4];
    

}

-(void)menu:(SelectButton *)btn{
    NSLog(@"111");
    if (_selectedIndex == btn.tag) {
        NSLog(@"22");
        btn.textlabel.textColor=SELECTED_TEXTCOLOR;
        btn.line.backgroundColor=SELECTED_TEXTCOLOR;
        _selectedIndex = -1;
    }
    else{
        NSLog(@"333");
        for (int i=0; i<buttonList.count; i++) {
           SelectButton *btns = [buttonList objectAtIndex:i];
            if (i == btns.tag) {
                btns.textlabel.textColor=SELECTED_TEXTCOLOR;
                btns.line.backgroundColor=SELECTED_TEXTCOLOR;
            }
            else{
                btns.textlabel.textColor=SELECTED_TEXTCOLOR;
                btns.line.backgroundColor=TEXTCOLOR;
            }
        }
        _selectedIndex = btn.tag;
    }
//    
//    if (_selectedIndex == -1) {
//        self.corverView.hidden = YES;
//    }
//    else{
//        self.corverView.hidden = NO;
//    }
//    
//    [self.selectedDelegate segBtnDidSelectedAtIndex:_selectedSegmentIndex];
    
}
/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
